package cn.wegoteam.shop.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.stereotype.Controller;

import cn.wegoteam.shop.enu.AgentType;
import cn.wegoteam.shop.inter.AgentServiceInter;
import cn.wegoteam.shop.po.Agent;
import cn.wegoteam.shop.util.AuthImg;
import cn.wegoteam.shop.util.Const;
import cn.wegoteam.shop.util.OSSObjectSample;

@ParentPackage("users")
@Namespace("/")
@Controller
public class AgentInteceptorAction extends BaseAction<Agent> {
	@Resource
	private AgentServiceInter agentService;
	@Action(value = "saveAgent")
	public void saveAgent() {
         model.setUser(getSessionUser());
         if(model.getType().equals(AgentType.COMPANY)){
        	 model.setType(AgentType.COMPANY);
         }else{
        	 model.setType(AgentType.PERSON);
         }
         String result=agentService.save(model);
         if(result.equals(Const.RETURNSUCCESS)){
        	 writeStringToResponse("[OK]");
         }else{
        	 writeStringToResponse("[ERROR]");
         }
	}
	
}
